#!/usr/bin/env bash

set -e

# We need a writable home directory for mitmproxy
mount -t tmpfs none /home
mkdir /home/user
chown user:user /home/user

# Host the exploit in /tmp
mount -t tmpfs none /tmp
cd /tmp
tar -xf /exploit.tar.gz

# Allow participants to bring their own doit.sh
if ! [ -f /tmp/doit.sh ]; then
  cp /doit.sh /tmp/
fi

# Run as user
su -c /tmp/doit.sh - user
